Random character strings have been extensively used in many services (e.g., communication services, transaction services, etc.). For example, services with an extensive use of random character strings can be a service comprising a cryptographic process, a service that needs to label a large amount of service data, and the like.
At present, to prevent confusion among service data, it is typically required that random character strings used by a service are unique in the scope of the service, namely the random character strings should be different from each other.
According to existing technologies, a random algorithm is typically used to generate random character strings. Moreover, a currently generated random character string is compared with random character strings generated previously. If they are the same, the currently generated random character string is discarded, and a random character string is further generated. As such, each of the generated and saved random character strings is unique among all random character strings (for ease of description, the random character string can be referred to as a unique random character string).
When there is a large number of generated and saved random character strings, however, the operation to compare character strings needs to be carried out for many times when generating a random character string to prevent having identical random character strings. Therefore, this method for generating a unique random character string has a very low efficiency.